<!DOCTYPE html>
<html lang="zh-cn">
    <head>
        <meta charset="UTF-8"/>
        <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
        <title>类-静态方法</title>
    </head>
    <body>
        <h1>类-静态方法</h1>
        <p>来源:<a href="https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Classes">https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Classes</a></p>
        <script>
            class Point {
                constructor(x, y) {
                    this.x = x;
                    this.y = y;
                }

                static distance(a, b) {
                    const dx = a.x - b.x;
                    const dy = a.y - b.y;

                    return Math.hypot(dx, dy);
                }
            }

            const p1 = new Point(5, 5);
            const p2 = new Point(10, 10);

            console.log(Point.distance(p1, p2));
        </script>
    </body>
</html>